package com.example.administrator.myrxjavademo.net;

import com.example.administrator.myrxjavademo.net.exception.ApiException;
import com.example.administrator.myrxjavademo.net.model.HttpResult;

import rx.functions.Func1;

/**
 * Created by Administrator on 2017\8\17 0017.
 */

public class HttpResultFunc<T> implements Func1<HttpResult<T>,T> {
    @Override
    public T call(HttpResult<T> tHttpResult) {
        if ("0".equals(tHttpResult.ret)) {
            return tHttpResult.data;
        } else {
            if ("350".equals(tHttpResult.ret)){
//                Intent intent = new Intent(BaseActivity.context, LoginRegisterActivity.class);
//                BaseActivity.context.startActivity(intent);
            }
          throw new ApiException(tHttpResult.msg);
        }
    }
}
